package com.spoplar.test;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.TextMessage;

import com.spoplar.lsm.Smsapi;

public class QueueListener implements MessageListener {

	@Override
	public void onMessage(Message message) {
		
		try {
		   //String str = 	((TextMessage)message).getText();
		   //System.out.println(str);
		   
//			Email email=(Email)((ObjectMessage)message).getObject();
			Sms sms=(Sms)((ObjectMessage)message).getObject();
//			System.out.println(email.getFrom());
//			System.out.println(email.getTo());
//			System.out.println(email.getTitle());
//			System.out.println(email.getSubject());
//			System.out.println(email.getBody());
//			System.out.println("---------------------------------->");
			
			Smsapi smsapi = new Smsapi();
			smsapi.sendMsg(sms.getPhone(), sms.getMsg());
			message.acknowledge();
		   //throw new RuntimeException();
		} catch (JMSException e) {
			e.printStackTrace();
		}
		
	}

}
